package com.jstide.credit.data.service.biz;

import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Entity;
import com.jstide.credit.data.service.Algorithm;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.ResultSet;
import java.util.List;
import java.util.Optional;

public class Factor14 extends Algorithm {

    public static final Logger logger = LoggerFactory.getLogger(Factor14.class);

    @Getter
    public final  String name="14";

    //职业技能/专业技术职务信息
    //“一级、高级”10分；“二级、中级”8分；“三级、助理”6分；“四级”5分；“五级”3分；其他值3分
    //10
    @Getter
    public  final String sql ="    select  ZYJNZYJSDJ from ZRRZYJNZYJSZWXX where join_id=@joinId    ";

    @Override
    public int translate(String rs) {
        return 0;
    }


    @Override
    public int translate(List<Entity> rs) {
        int score=0;
        if(null!=rs && rs.size()>0){

            score = rs.stream().filter(t-> {
                        String dj = t.getStr("ZYJNZYJSDJ");
                        return  StrUtil.equals(dj, "一级") || StrUtil.equals(dj, "高级");
                    }
                   ).count()>0 ? 10 :0;

            if(0==score){
                score = rs.stream().filter(t-> {
                    String dj = t.getStr("ZYJNZYJSDJ");
                    return  StrUtil.equals(dj, "二级") || StrUtil.equals(dj, "中级");
                }).count()>0 ? 8:0;
            }
            if(0==score){
                score = rs.stream().filter(t-> {
                    String dj = t.getStr("ZYJNZYJSDJ");
                    return  StrUtil.equals(dj, "三级") || StrUtil.equals(dj, "助理");
                }).count()>0 ? 6:0;
            }
            if(0==score){
                score = rs.stream().filter(t-> {
                    String dj = t.getStr("ZYJNZYJSDJ");
                    return  StrUtil.equals(dj, "四级");
                }).count()>0 ? 5:0;
            }
            if(0==score){
                score = rs.stream().filter(t-> {
                    String dj = t.getStr("ZYJNZYJSDJ");
                    return  StrUtil.equals(dj, "五级");
                }).count()>0 ? 3:0;
            }
            if(0==score){
                score = rs.stream().filter(t-> {
                    String dj = t.getStr("ZYJNZYJSDJ");
                    return  StrUtil.isNotBlank(dj);
                }).count()>0 ? 3:0;
            }


        }

        return score;
    }
}
